package Aggregation;

public class DiplomaPG {
	// Holds the name of the Diploma.
	String name;
	// Holds the Diplomas Modules.
	Module[] modules = new Module[6];
	// Holds the number of Modules currently in the Diploma.
	int numModules;
	
	// Empty constructor allows Diploma to be created before Modules are added.
	DiplomaPG(String aName) {
		name = aName;
		numModules = 0;
	}
	
	// Constructor takes and array of Modules to initialize the Diploma.
	DiplomaPG(String aName, Module[] moduleSet) {
		name = aName;
		// Test the array has the correct amount of Modules within.
		if (moduleSet.length == 6) {
			modules = moduleSet;
			numModules = 6;
		}
		else {
			System.out.println("Modules not set, array did not contain 6 Modules!");
			numModules = 0;
		}
	}
	
	// Add a Module to the Diploma.
	public void addModule(Module aModule) {
		if (numModules < 6) {
			modules[numModules] = aModule;
			++numModules;
		}
		else {
			System.out.println("There are already the maximum 6 modules in this Diploma!");
		}
	}
	
	// Prints the details of the Diploma.
	public void printDetails() {
		System.out.println(name);
		for (int i=0; i < numModules; ++i) {
			modules[i].printDetails();
		}
	}
}